package com.designoutput.utils
{
	public class ColorUtil
	{
		public function ColorUtil()
		{
		}
		
		public static function getSumColor(clr1:Number, clr2:Number, alpha:Number):Number
		{
			var r1:Number = getR(clr1) * alpha / 100;
			var g1:Number = getG(clr1) * alpha / 100;
			var b1:Number = getB(clr1) * alpha / 100;
			var r2:Number = getR(clr2) * (100 - alpha) / 100;
			var g2:Number = getG(clr2) * (100 - alpha) / 100;
			var b2:Number = getB(clr2) * (100 - alpha) / 100;
			return getColor(Math.floor(r1 + r2), Math.floor(g1 + g2), Math.floor(b1 + b2));
		}
		
		public static function getR(color:Number):Number
		{
			return Math.floor((color & 0xff0000) / 256 / 256);
		}
		
		public static function getG(color:Number):Number
		{
			return Math.floor((color & 0x00ff00) / 256);
		}
		
		public static function getB(color:Number):Number
		{
			return color & 0x0000ff;
		}
		
		public static function getColor(r:Number, g:Number, b:Number):Number
		{
			return r * 256 * 256 + g * 256 + b;
		}
	}
}